<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
</head>

<body>
    <input type="text" value="你">
    <div class="content">
    </div>
    <script>
        /* 1.获取value发送http请求 */
        // $("div").children().remove()
        /* 2.按下键盘再次发送http请求 */
        var url = "https://music.aityp.com/search"
        var value = $("input").val();
        $.ajax({
            url: `${url}?keywords=${value}&limit=10`,
            success: res => {
                var songs = res.result.songs;
                songs.forEach(item => {
                    var element = `
                       <p>${item.name}</p>
                       `
                    $('.content').append(element)
                })
            }
        })
        $("input").keydown(function (event) {
            if (event.keyCode == 13) {
                var value = $("input").val();
                $.ajax({
                    url: `${url}?keywords=${value}&limit=10`,
                    success: res => {
                        var songs = res.result.songs;
                        songs.forEach(item => {
                            var element = `
                       <p>${item.name}<p>
                       `
                            $('.content').append(element)
                        })
                    },
                    beforeSend(){
                        $(".content").children().remove()
                    }
                })
            }
        })
    </script>

</body>

</html>